package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {
    @Select("select count(id) from dish where category_id=#{id}")
    Integer countByCategoryId(Long id);
    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    void insertBatch(List<DishFlavor> flavors);

    Page<DishVO> page(DishPageQueryDTO dishPageQueryDTO);

    DishVO getById(Long id);

    List<DishFlavor> geByIdWithFlavor(Long id);
    @Select("select * from dish where category_id=#{categoryId}")
    List<Dish> getDishByCategoryId(Long categoryId);
    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);
    @Delete("delete from dish_flavor where dish_id=#{id}")
    void deleteFlavorByDishId(Long id);

    void deleteByIds(List<Long> ids);

    List<Dish> list(Dish dish);

    Integer countByMap(Map map);
}
